
import java.util.concurrent.ExecutorService;

import org.apache.jasper.servlet.JspServlet;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.util.ajax.Continuation;
import org.mortbay.util.ajax.ContinuationSupport;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;


import Commnads.Commands;
import Commnads.GuiCommands;
import UI.ContInitServ;
import UI.OurGUI;
import UI.PauseInitServ;
import UI.PrgrsBar;
import UI.SearchServ;
import UI.StartInitServ;
import UI.StartLisServ;
import UI.StopInitServ;
import UI.StopLisServ;


public class Main 
{

	public static void main(String[] args) 
	{
		BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("RunP.xml"));
		OurGUI gui=(OurGUI)beanFactory.getBean("gui");
		GuiCommands com = (GuiCommands)beanFactory.getBean("guiCom");
		

		Server server = new Server(8085);
		Context root = new Context(server,"/",Context.SESSIONS);

		root.setResourceBase("WebContent/WEB-INF");
		root.addServlet(new ServletHolder(new JspServlet()),"/pre.jsp");
		root.addServlet(new ServletHolder(new StartLisServ(com)), "/StartLisServ");
		root.addServlet(new ServletHolder(new StopLisServ(com)), "/StopLisServ");
		root.addServlet(new ServletHolder(new StartInitServ(com)), "/StartInitServ");
		root.addServlet(new ServletHolder(new StopInitServ(com)), "/StopInitServ");
		root.addServlet(new ServletHolder(new PauseInitServ(com)), "/PauseInitServ");
		root.addServlet(new ServletHolder(new ContInitServ(com)), "/ContInitServ");
		root.addServlet(new ServletHolder(new SearchServ(com)), "/SearchServ");
		root.addServlet(new ServletHolder(new PrgrsBar(com)), "/ProgressBar");
		
		try 
		{
			server.start();
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
		}
		
		gui.init();
		((ExecutorService)gui.getExecutor()).shutdown();
		try 
		{
			server.stop();
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
		}
	}
}
